import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { rules } from '@pkg/utils';
import { render } from '@apps/antd-admin/src/hooks/render/renderUtils';
import { RenderType } from '@pkg/setting';
import { weChatList } from '@apps/ant-bus/src/views/business/platformManage/wechat/data/api';

export const columns: BasicColumn[] = [
  {
    title: '封面图',
    dataIndex: 'sliderImg',
    width: 70,
    customRender: render.renderImage,
  },
  {
    title: '标题',
    dataIndex: 'sliderTitle',
    width: 130,
  },
  {
    title: '类型',
    dataIndex: 'sliderType',
    width: 60,
    align: 'center',
    customRender: render.renderDict,
  },
  {
    title: '跳转方式',
    dataIndex: 'jumpType',
    width: 60,
    dictData: [
      { label: '跳转链接', value: 1 },
      { label: '图文内容', value: 2 },
      { label: '图片展示', value: 3 },
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '发布状态',
    dataIndex: 'sendStatus',
    width: 60,
    dictCode: 'publishStatus',
    customRender: render.renderDict,
  },
  {
    title: '排序',
    dataIndex: 'sortOrder',
    width: 40,
    sorter: {
      multiple: 1,
    },
  },
  {
    title: '创建日期',
    dataIndex: 'createTime',
    width: 80,
    sorter: {
      multiple: 2,
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'sliderTitle',
    label: '标题',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'sliderType',
    label: '轮播图类型',
    component: 'ApiSelect',
    colProps: { span: 5 },
    componentProps: {
      dictCode: 'sliderType',
      stringToNumber: true,
    },
  }
];

export const formSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'sliderTitle',
    component: 'Input',
    required: true,
  },
  {
    label: '轮播图类型',
    field: 'sliderType',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      dictCode: 'sliderType',
      stringToNumber: true,
    },
  },
  {
    label: '跳转方式 ',
    field: 'jumpType',
    required: true,
    component: 'ApiRadioGroup',
    componentProps: {
      options: [
        { label: '跳转链接', value: 1 },
        { label: '图文内容', value: 2 },
        { label: '图片展示', value: 3 },
      ],
    },
  },
  {
    label: '跳转地址',
    field: 'content',
    component: 'Input',
    rules: rules.url(true),
    ifShow: ({ values }) => {
      return values.jumpType == '1';
    },
  },
  {
    label: '内容',
    field: 'content',
    component: 'TyEditor',
    required: true,
    componentProps:{
      height:800
    },
    ifShow: ({ values }) => {
      return values.jumpType == '2';
    },
  },
  {
    label: '排序号',
    field: 'sortOrder',
    component: 'InputNumber',
    required: true,
    defaultValue: 0
  },
  {
    label: '图片',
    field: 'sliderImg',
    component: 'ImageUpload',
    itemProps:{
      extra:"建议尺寸750*150",
    },
  },
];
